<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-cache,no-store">
    <meta http-equiv="Expires" content="0">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <title>成员编辑</title>
    <link rel="stylesheet" th:href="@{/plugins/layui/css/layui.css}" media="all" />
    <link rel="stylesheet" th:href="@{/plugins/font-awesome/css/font-awesome.min.css}" media="all" />
    <link rel="stylesheet" th:href="@{/src/css/app.css}" media="all" />
    <link rel="stylesheet" th:href="@{/src/css/themes/default.css}" media="all" id="skin" kit-skin />
</head>
<body class="layui-container">
<br/>
<form class="layui-form" th:action="${record.staffId == null ? '/auth/staff/createStaff.json' : '/auth/staff/updateStaff.json'}" method="POST">
    <input type="hidden" name="staffId" th:value="${record.staffId}"/>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="loginName" th:if="${record.staffId == null}" placeholder="请输入用户名" maxlength="20" lay-verify="required" autocomplete="off" class="layui-input">
                <input type="text" name="loginName" th:if="${record.staffId != null}" readonly="readonly" th:value="${record.loginName}" maxlength="20" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-block">
                <input type="text" name="realName" th:value="${record.realName}" maxlength="20" lay-verify="required" autocomplete="off" placeholder="请输入真实姓名" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block" th:if="${record.staffId == null}">
                <input type="radio" name="sex" value="MALE" title="男" checked="">
                <input type="radio" name="sex" value="FEMALE" title="女">
            </div>
            <div class="layui-input-block" th:if="${record.staffId != null}">
                <input type="radio" name="sex" value="MALE" title="男" th:checked="${record.sex eq 'MALE'}">
                <input type="radio" name="sex" value="FEMALE" title="女" th:checked="${record.sex eq 'FEMALE'}">
            </div>
        </div>
        <div class="layui-inline" style="margin-left: 50px;">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                <input name="mobile" placeholder="请输入手机号码" maxlength="11" lay-verify="required|phone" class="layui-input" th:value="${record.mobile}"></input>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">固定号码</label>
            <div class="layui-input-block">
                <input name="telephone" placeholder="请输入固定号码" maxlength="50" class="layui-input" th:value="${record.telephone}"></input>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
                <input name="email" placeholder="请输入邮箱" maxlength="100" lay-verify="required|email" class="layui-input" th:value="${record.email}"></input>
            </div>
        </div>
    </div>
    <th:block th:if="${record.staffId == null}">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">初始密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" id="pwd" maxlength="20" lay-verify="required" autocomplete="off" placeholder="请输入初始密码" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-block">
                    <input type="password" name="regpass" id="regPwd" maxlength="20" lay-verify="required|regPwd"  autocomplete="off" placeholder="请输入确认密码" class="layui-input">
                </div>
            </div>
        </div>
    </th:block>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="save">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            <button class="layui-btn" id="resetPwd">重置密码</button>
        </div>
    </div>
</form>
<!-- 引用layer基本js -->
<script th:src="@{/plugins/layui/layui.js}"></script>
<script>
    layui.config({
        base : '../../build/js/',
        version : '1.0.1'
    }).use(['form', 'common'], function() {
        var app = layui.app, $ = layui.jquery, layer = layui.layer,
            common = layui.common, form = layui.form;

        form.verify({
            regPwd: function(value) {
                //获取密码
                var pwd = $("#pwd").val();
                if(pwd != value) {
                    return '两次输入的密码不一致';
                }
            }
        });
        /**保存*/
        form.on("submit(save)", function(data) {
            var url = $(".layui-form").attr("action");

            //异步表单提交
            common.fromPostAjax(url, data.field);
            return false;
        });
    })
</script>
</body>
</html>